<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Js运算符</title>
</head>
<body>
<script>
    console.log(3/2);
    console.log(6/2);
    console.log(3>10);
    console.log(3>'10');
    console.log('3'>10);
    console.log("**************")
    //如果比较运算符左右两边都是字符串，会比较他们的编码值
    // '3'.charCodeAt() 查看字符串3的编码值
    console.log('3'>'10');//true 51>49
    console.log('超'>'博');
    console.log('3'.charCodeAt());//51
    console.log('10'.charCodeAt(0));//49
    console.log('1'.charCodeAt());//49


    console.log(Number('3'),typeof Number('3'));//3 'number'
    console.log(Number(true),typeof Number(true));//1 'number'
    console.log(Number(false),typeof Number(false));//0 'number'
    console.log(Number('你好'),typeof Number('你好'));//NaN 'number'

    let a = 1;
    let b = true;
    //松散比较运算符，只比较值，Number(true)=1
    console.log(a == b);
    //严格比较运算符，先比较类型，在比较值 number ≠ boolean
    console.log(a === b);

    console.log(Boolean(0));
    console.log(Boolean(''));
    console.log(Boolean(null));
    console.log(Boolean(undefined));
    console.log(Boolean(NaN));
    console.log(Boolean(' '));
    console.log(Boolean('下午好！'));

    //三元运算符
    let c = 0;
    console.log(c==0 ? 'yes' : 'no');
    //=是赋值符号，给c赋值0，Boolean(0)=flase,所以是no
    console.log(c=0 ? 'yes' : 'no');
</script>
</body>
</html>